--- external/eg3d/training/volumetric_rendering/ray_sampler.py	2023-03-14 23:35:46.915278482 +0000
+++ external_reference/eg3d/training/volumetric_rendering/ray_sampler.py	2023-03-14 23:28:05.430774723 +0000
@@ -35,7 +35,7 @@
         N, M = cam2world_matrix.shape[0], resolution**2
         cam_locs_world = cam2world_matrix[:, :3, 3]
         fx = intrinsics[:, 0, 0]
-        fy = intrinsics[:, 1, 1]
+        fy = -intrinsics[:, 1, 1] # follow opengl convention from nerf
         cx = intrinsics[:, 0, 2]
         cy = intrinsics[:, 1, 2]
         sk = intrinsics[:, 0, 1]
@@ -51,7 +51,8 @@
         x_lift = (x_cam - cx.unsqueeze(-1) + cy.unsqueeze(-1)*sk.unsqueeze(-1)/fy.unsqueeze(-1) - sk.unsqueeze(-1)*y_cam/fy.unsqueeze(-1)) / fx.unsqueeze(-1) * z_cam
         y_lift = (y_cam - cy.unsqueeze(-1)) / fy.unsqueeze(-1) * z_cam
 
-        cam_rel_points = torch.stack((x_lift, y_lift, z_cam, torch.ones_like(z_cam)), dim=-1)
+        # follow opengl convention like nerf
+        cam_rel_points = torch.stack((x_lift, y_lift, -z_cam, torch.ones_like(z_cam)), dim=-1)
 
         world_rel_points = torch.bmm(cam2world_matrix, cam_rel_points.permute(0, 2, 1)).permute(0, 2, 1)[:, :, :3]
 
@@ -60,4 +61,4 @@
 
         ray_origins = cam_locs_world.unsqueeze(1).repeat(1, ray_dirs.shape[1], 1)
 
-        return ray_origins, ray_dirs
\ No newline at end of file
+        return ray_origins, ray_dirs
